I am developing an application in .net with visual c# for windows
mobile 5.
I have the list of running programs and their handles. How can I get
their icon so I can populate an imagelist ?
Thanks !
[DllImport("Coredll")]
extern static int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
Once you have hIcon, you can use Icon.FromHandle to get a .NET Icon object
<stei...@yahoo.com> wrote in message
news:1143049727....@j33g2000cwa.googlegroups.com...
I wonder if it is better to find the executable that launched the
window and get the icon from there using SHGetFileInfo(), which seems
to work very well. But it seems to be dificult.
I would really appreciate any other suggestions. Thanks again !
<stei...@yahoo.com> wrote in message
news:1143079764....@j33g2000cwa.googlegroups.com...
I get the process ID using: GetWindowThreadProcessId();
In order to use GetModuleFileName() I need the process handle instead
of the ID.
So I use OpenProcess(), but it always returns 0
This is an example of my code: (handle is the window handle)
string path = new string(' ', 255);
IntPtr ThreadID =GetWindowThreadProcessId(handle, IntPtr.Zero);
IntPtr processHwnd = OpenProcess(0, false, (int)ThreadID);
GetModuleFileName(processHwnd.ToInt32(), path, path.Length);
Is it that OpenProcess() is used in the msdn example so it should be
supported. I don't understand what is wrong ?
[DllImport("coredll.dll")]
private static extern IntPtr OpenProcess(uint flags, bool
fInherit, int PID);
private const uint PROCESS_ALL_ACCESS = 0x1F0FFF;
IntPtr processHwnd = OpenProcess(PROCESS_ALL_ACCESS, false,
(int)ThreadID);
But the result is the same :( Any help would be greately appreciated.
Thanks !
Thanks for pointing me to the right direction !